package com.project.controller;

import com.github.pagehelper.PageInfo;
import com.project.entity.Member;
import com.project.entity.RestPOJO;
import com.project.service.AdminMemberService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags="管理员会员管理接口")//tags:说明信息
public class AdminMemberController {

    @Autowired
    private AdminMemberService adminMemberService;


    @ApiOperation(
            value = "搜索所有会员信息",
            httpMethod = "GET",
            protocols = "HTTP",
            produces = "application/json",
            response = RestPOJO.class
    )
    //方法的参数说明
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query",name="currentPage",value="当前页",required=true),
            @ApiImplicitParam(paramType="query",name="pageSize",value="每页显示的条目数",required=true)
    })

    @RequestMapping("/selAllMember")
    public RestPOJO selAllMember(String keyWord,Integer currentPage,Integer pageSize){
        RestPOJO restPOJO = new RestPOJO();
        PageInfo<Member> memberPageInfo = adminMemberService.selAllMember(keyWord, currentPage, pageSize);
        if(memberPageInfo != null && memberPageInfo.getList().size() > 0){
            restPOJO.setStatus(1000);
            restPOJO.setMessages("查询成功");
            restPOJO.setData(memberPageInfo);
        }else{
            restPOJO.setStatus(1001);
            restPOJO.setMessages("查询失败");
        }
        return restPOJO;
    }
}
